package com.ltxtiyu.video.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ltxtiyu.video.service.ms.CityWideService;
import com.ltxtiyu.video.service.ms.TopicService;
import com.ltxtiyu.video.tool.StringUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.HashMap;
import java.util.Map;

@RequestMapping("cityWideController")
@Controller
public class CityWideController {

    @Reference
    private CityWideService cityWideService;

    /**
     * 条件查询列表
     * @param page
     * @param limit
     * @param name
     * @return
     */
    @RequestMapping(value = "paramlist",method = RequestMethod.GET)
    public ResponseEntity<Map<String ,Object>> queryById(int page,int limit, String name){
        try {
            Map<String,Object> map = new HashMap<>();
            map.put("page",(page-1)*limit);
            map.put("row",limit);
            Map<String,Object> result = cityWideService.selectParamList(map);

            return ResponseEntity.ok(result);
        }catch (Exception e){
            e.printStackTrace();
            return  ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
        }

    }

    //删除
    @RequestMapping("delById")
    public ResponseEntity<Void> delById(Integer id){
        try {
            if (id.longValue() <1){
                return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
            }
            return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
        }catch (Exception e){
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
        }

    }

}
